// -----------------------------------------------------------------------------
//
// Work is licensed by Arthur Fermi (C)2008-2011,
// patches are licensed by Mirella Dallagio (C)2011
// under Creative Commons Attribution-Share Alike 3.0 Unported License
// To receive a copy of this license please visit
// http://creativecommons.org/licenses/by-sa/3.0/
//
// You are free to copy, distribute, transmit and adapt the work
// under the following conditions:
//
// You must attribute the work in the manner specified by the 
// author(s) or licensor (but not in any way that suggests that 
// they endorse you or your use of the work). 
//
// If you alter, transform, or build upon this work in any way,
// you may distribute the resulting work only under the same or 
// similar license to this one. 
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See points (6) and (7) of the license for more details.
//
// -----------------------------------------------------------------------------
// Do not change anything below here or you will likely break something
// -----------------------------------------------------------------------------

// SimNet - Parcel Info

// Global Variables
integer gintOnOff;      // 0 = Off 1 = On

 
funGetInfo()
{
    string strPrims = (string)llGetParcelDetails(llGetPos(),[PARCEL_DETAILS_NAME]) +
    "\nMax: " + (string)llGetParcelMaxPrims(llGetPos(), FALSE) + 
    " ~ Used: " + (string)llGetParcelPrimCount(llGetPos(), 0, 0) + 
    " ~ Left: " + (string)(llGetParcelMaxPrims(llGetPos(), FALSE) - llGetParcelPrimCount(llGetPos(), 0, 0));
    llSetText(strPrims, <1,1,1>,1);    
}

funStatus()
{
    if (gintOnOff == 0)
    {
        gintOnOff = 1;
        llSetText("", <1,1,1>, 1);
        funGetInfo();
        llSetTimerEvent(5);
    }
    else if (gintOnOff == 1)
    {
        gintOnOff = 0;
        llSetText("", <1,1,1>, 1);
        llSetTimerEvent(0);
    }
}


default
{
    state_entry()
    {
        gintOnOff = 0;
        funStatus();
    }

    timer()
    {
        funGetInfo(); 
    } 
    on_rez(integer start_param)
    {
        llSetScriptState(llGetScriptName(), FALSE);
        llResetScript();    
    }
}